package com.ruibang.glass.quality.controller.kf;

import com.ruibang.glass.quality.domain.req.EightDReportReq;
import com.ruibang.glass.quality.entity.EightDReport;
import com.ruibang.glass.quality.service.EightDReportService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * <p>
 * 8D报告 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-05-21
 */
@RestController
@RequestMapping("/api/g/quality/eight/d/report")
@Api(value = "8D报告控制器", tags = {"8D报告接口"})
public class EightDReportController {


    @Autowired
    private EightDReportService eightDReportService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取8D报告", notes = "获取8D报告")
    public ResultBody getById(@PathVariable(value = "id") Integer id) {
        return ResultBody.success(eightDReportService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增8D报告", notes = "新增8D报告")
    public ResultBody saveReport(@RequestBody @Valid EightDReport eightDReport) {
        eightDReportService.saveReport(eightDReport);
        return ResultBody.success();
    }

    @GetMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除8D报告", notes = "通过ID删除8D报告")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        eightDReportService.removeById(id);
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改8D报告", notes = "修改8D报告")
    public ResultBody updateReport(@RequestBody @Valid EightDReport eightDReport) {
        eightDReportService.updateReport(eightDReport);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询8D报告", notes = "分页列表查询8D报告")
    public ResultBody pageQuery(@RequestBody EightDReportReq eightDReportReq) {
        return ResultBody.success(eightDReportService.pageQuery(eightDReportReq));
    }
}
